import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import matplotlib.pyplot as plt # plotting
import seaborn as sns # plotting heatmap
%matplotlib inline
df = pd.read_csv('D:\Github\django-shop\handpose-mouse-simulation\postion_data\Chinese_seven.csv',
)
df2 = pd.read_csv('D:\Github\django-shop\handpose-mouse-simulation\\target_data\Chinese_seven.csv',
)
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 2609 entries, 0 to 2608 Data columns (total 63 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 x0 2609 non-null float64 1 y0 2609 non-null float64 2 z0 2609 non-null float64 3 x1 2609 non-null float64 4 y1 2609 non-null float64 5 z1 2609 non-null float64 6 x2 2609 non-null float64 7 y2 2609 non-null float64 8 z2 2609 non-null float64 9 x3 2609 non-null float64 10 y3 2609 non-null float64 11 z3 2609 non-null float64 12 x4 2609 non-null float64 13 y4 2609 non-null float64 14 z4 2609 non-null float64 15 x5 2609 non-null float64 16 y5 2609 non-null float64 17 z5 2609 non-null float64 18 x6 2609 non-null float64 19 y6 2609 non-null float64 20 z6 2609 non-null float64 21 x7 2609 non-null float64 22 y7 2609 non-null float64 23 z7 2609 non-null float64 24 x8 2609 non-null float64 25 y8 2609 non-null float64 26 z8 2609 non-null float64 27 x9 2609 non-null float64 28 y9 2609 non-null float64 29 z9 2609 non-null float64 30 x10 2609 non-null float64 31 y10 2609 non-null float64 32 z10 2609 non-null float64 33 x11 2609 non-null float64 34 y11 2609 non-null float64 35 z11 2609 non-null float64 36 x12 2609 non-null float64 37 y12 2609 non-null float64 38 z12 2609 non-null float64 39 x13 2609 non-null float64 40 y13 2609 non-null float64 41 z13 2609 non-null float64 42 x14 2609 non-null float64 43 y14 2609 non-null float64 44 z14 2609 non-null float64 45 x15 2609 non-null float64 46 y15 2609 non-null float64 47 z15 2609 non-null float64 48 x16 2609 non-null float64 49 y16 2609 non-null float64 50 z16 2609 non-null float64 51 x17 2609 non-null float64 52 y17 2609 non-null float64 53 z17 2609 non-null float64 54 x18 2609 non-null float64 55 y18 2609 non-null float64 56 z18 2609 non-null float64 57 x19 2609 non-null float64 58 y19 2609 non-null float64 59 z19 2609 non-null float64 60 x20 2609 non-null float64 61 y20 2609 non-null float64 62 z20 2609 non-null float64 dtypes: float64(63) memory usage: 1.3 MB
df.head()
| x0 | y0 | z0 | x1 | y1 | z1 | x2 | y2 | z2 | x3 | ... | z17 | x18 | y18 | z18 | x19 | y19 | z19 | x20 | y20 | z20 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0.588279 | 0.687364 | -0.000058 | 0.553355 | 0.663248 | -0.002852 | 0.536861 | 0.606557 | -0.021549 | 0.524479 | ... | -0.071636 | 0.572576 | 0.586915 | -0.092522 | 0.568609 | 0.622625 | -0.079594 | 0.579497 | 0.640591 | -0.065896 |
| 1 | 0.588614 | 0.689675 | -0.000064 | 0.553241 | 0.661748 | 0.001669 | 0.536016 | 0.607307 | -0.015098 | 0.523905 | ... | -0.070888 | 0.570480 | 0.587335 | -0.089173 | 0.567368 | 0.622707 | -0.077386 | 0.578273 | 0.641378 | -0.064499 |
| 2 | 0.586556 | 0.691868 | -0.000073 | 0.551673 | 0.661805 | 0.000363 | 0.534590 | 0.606866 | -0.017144 | 0.522370 | ... | -0.070475 | 0.569727 | 0.586521 | -0.088980 | 0.567061 | 0.622435 | -0.076765 | 0.578557 | 0.641623 | -0.063537 |
| 3 | 0.589569 | 0.695159 | -0.000055 | 0.553746 | 0.663853 | 0.001502 | 0.536343 | 0.609131 | -0.016101 | 0.523076 | ... | -0.069789 | 0.569331 | 0.587703 | -0.085456 | 0.567234 | 0.623264 | -0.073273 | 0.579543 | 0.640219 | -0.060835 |
| 4 | 0.589958 | 0.698058 | -0.000064 | 0.554912 | 0.664763 | 0.004362 | 0.537255 | 0.611345 | -0.011062 | 0.524839 | ... | -0.066170 | 0.571998 | 0.589540 | -0.079986 | 0.570188 | 0.625389 | -0.068290 | 0.582433 | 0.643111 | -0.057089 |
5 rows × 63 columns
df.describe()
| x0 | y0 | z0 | x1 | y1 | z1 | x2 | y2 | z2 | x3 | ... | z17 | x18 | y18 | z18 | x19 | y19 | z19 | x20 | y20 | z20 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| count | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | ... | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 | 2609.000000 |
| mean | 0.561361 | 0.610462 | -0.000042 | 0.535539 | 0.576024 | -0.002198 | 0.520824 | 0.510569 | -0.017301 | 0.514195 | ... | -0.060590 | 0.548124 | 0.466603 | -0.090267 | 0.545726 | 0.501308 | -0.087598 | 0.552539 | 0.523871 | -0.080541 |
| std | 0.117577 | 0.155643 | 0.000034 | 0.113377 | 0.148368 | 0.027114 | 0.117840 | 0.146205 | 0.032388 | 0.127809 | ... | 0.056258 | 0.136597 | 0.159210 | 0.052114 | 0.131283 | 0.158199 | 0.055526 | 0.126676 | 0.159470 | 0.062044 |
| min | 0.000000 | 0.000000 | -0.000280 | 0.000000 | 0.000000 | -0.150558 | 0.000000 | 0.000000 | -0.255492 | 0.000000 | ... | -0.270283 | 0.000000 | 0.000000 | -0.354165 | 0.000000 | 0.000000 | -0.417686 | 0.000000 | 0.000000 | -0.464105 |
| 25% | 0.497981 | 0.487984 | -0.000057 | 0.473636 | 0.461210 | -0.020075 | 0.439839 | 0.390517 | -0.034923 | 0.419352 | ... | -0.083197 | 0.466061 | 0.332624 | -0.106323 | 0.470148 | 0.382557 | -0.100213 | 0.488226 | 0.416695 | -0.088580 |
| 50% | 0.570350 | 0.635907 | -0.000037 | 0.549373 | 0.591654 | -0.003276 | 0.537857 | 0.510321 | -0.013685 | 0.531835 | ... | -0.049543 | 0.560694 | 0.466195 | -0.077432 | 0.560572 | 0.514046 | -0.073953 | 0.570365 | 0.538854 | -0.063731 |
| 75% | 0.650696 | 0.709889 | -0.000020 | 0.623481 | 0.680246 | 0.010590 | 0.615680 | 0.620410 | 0.000013 | 0.619309 | ... | -0.020931 | 0.653239 | 0.590856 | -0.061346 | 0.646001 | 0.620967 | -0.058130 | 0.648004 | 0.641623 | -0.048262 |
| max | 0.757160 | 0.931839 | 0.000045 | 0.721734 | 0.908269 | 0.097229 | 0.720461 | 0.852178 | 0.094714 | 0.734952 | ... | 0.077458 | 0.784546 | 0.819508 | 0.020081 | 0.762023 | 0.857951 | 0.008688 | 0.751914 | 0.882951 | 0.015957 |
8 rows × 63 columns
## Plot the time series
plt.style.use('fivethirtyeight')
df.plot(subplots=True,
layout=(63, 3),
figsize=(22,22),
fontsize=10,
linewidth=2,
sharex=False,
title='Visualization of the original Time Series')
plt.show()
C:\Users\Qiao\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\plotting\_matplotlib\tools.py:400: MatplotlibDeprecationWarning: The is_first_col function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use ax.get_subplotspec().is_first_col() instead. if ax.is_first_col(): C:\Users\Qiao\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\plotting\_matplotlib\tools.py:400: MatplotlibDeprecationWarning: The is_first_col function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use ax.get_subplotspec().is_first_col() instead. if ax.is_first_col():
#heatmap visualization of the correlation matrix
corr_matrix = df.corr(method='spearman')
f, ax = plt.subplots(figsize=(16,8))
sns.heatmap(corr_matrix, annot=True, fmt='.2f', linewidth=0.4,
annot_kws={"size": 10}, cmap='coolwarm', ax=ax)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.show()
df_transform = df2.copy().pct_change(1)
df_transform.head()
| 0.6108246445655823 | 0.7414093613624573 | -1.7450931409257464e-05 | 0.5736578106880188 | 0.7333539128303528 | -0.026967162266373634 | 0.5405039191246033 | 0.6930084228515625 | -0.04962950199842453 | 0.5292852520942688 | ... | -0.059472326189279556 | 0.6099294424057007 | 0.6133171916007996 | -0.09297827631235123 | 0.5996366143226624 | 0.648635983467102 | -0.08817566931247711 | 0.5965439677238464 | 0.6814737915992737 | -0.07547677308320999 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 1 | -0.007395 | -0.021145 | -6.114154 | -0.017592 | -0.041910 | -0.171146 | -0.016039 | -0.051162 | -0.081320 | -0.017058 | ... | 0.034428 | -0.000296 | -0.053663 | 0.023380 | -0.008027 | -0.060220 | 0.098981 | -0.016668 | -0.057392 | 0.173286 |
| 2 | -0.006606 | -0.020439 | -0.263001 | -0.007250 | -0.022818 | -0.093176 | -0.007399 | -0.029314 | -0.046301 | -0.006417 | ... | -0.004210 | -0.008093 | -0.033725 | 0.016241 | -0.006286 | -0.028200 | -0.003716 | -0.005927 | -0.025903 | -0.037947 |
| 3 | -0.001761 | -0.023737 | 0.864003 | -0.004737 | -0.021633 | 0.522108 | -0.008633 | -0.024532 | 0.335937 | -0.005547 | ... | 0.168904 | -0.010165 | -0.024993 | 0.127894 | -0.005803 | -0.014558 | 0.065773 | -0.001526 | -0.015080 | 0.009086 |
| 4 | -0.005433 | -0.020225 | -0.570420 | -0.001490 | -0.021076 | -0.275870 | 0.002710 | -0.021583 | -0.259765 | -0.001647 | ... | -0.311983 | -0.004046 | -0.016519 | -0.242291 | -0.004097 | -0.014715 | -0.214409 | -0.003898 | -0.018799 | -0.214688 |
5 rows × 63 columns
plt.style.use('fivethirtyeight')
df_transform.plot(subplots=True,
layout=(63, 3),
figsize=(24,24),
fontsize=10,
linewidth=2,
title='Visualization of the transformed Features')
plt.show()
C:\Users\Qiao\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\plotting\_matplotlib\tools.py:400: MatplotlibDeprecationWarning: The is_first_col function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use ax.get_subplotspec().is_first_col() instead. if ax.is_first_col(): C:\Users\Qiao\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\plotting\_matplotlib\tools.py:400: MatplotlibDeprecationWarning: The is_first_col function was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Use ax.get_subplotspec().is_first_col() instead. if ax.is_first_col():